package com.example.gongj;

import java.io.*;
import java.util.HashMap;
import java.util.LinkedHashMap;

/**
 * 文本排序
 */
public class BufferedTest {
    public static void main(String[] args) throws Exception {
        HashMap<String, String> map = new HashMap<>();
        BufferedReader br = new BufferedReader(new FileReader("IO流\\e.txt"));
        BufferedWriter bw = new BufferedWriter(new FileWriter("IO流\\f.txt"));
        String line = null;
        while ((line = br.readLine()) != null){
            System.out.println(line);
            String[] split = line.split("\\.");
            map.put(split[0],line);
        }
        // 释放资源
        br.close();

        // 遍历map集合
        for (int i = 1 ;i< map.size(); i++) {
            String key = String.valueOf(i);
            String value = map.get(key);
            bw.write(key + "." + value);
            bw.newLine();
        }
        bw.close();
    }

}
